#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
const int ArraySize = 1e5 + 10;
ll a[ArraySize];
void solve()
{
    ll N;
    cin >> N;
    int i = 0, j = 0;
    ll ans = 0;
    for (i = 1; i <= N; i++)
    {
        cin >> a[i];
        for (j = i - 1; j > 0; j--)
        {
            if (a[i] == 10)
            {
                if ((a[j] * 100 + 10) % 36 == 0)
                    ans++;
            }
            else if ((a[j] * 10 + a[i]) % 36 == 0)
            {
                ans++;
            }
            if (a[j] == 10)
            {
                if ((a[i] * 100 + 10) % 36 == 0)
                    ans++;
            }
            else if ((a[i] * 10 + a[j]) % 36 == 0)
            {
                ans++;
            }
        }
    }
    cout << ans;
}
int main()
{
    solve();
    return 0;
}
